import commonJS from './common.js';
import config from './config.js';

const httpUpload = function(path){
	return new Promise((resolve, reject) => {
		let token = commonJS.getToken() || '';
		let header = {
			'accessToken': token,
		}
		uni.uploadFile({
					url: config.base_url + '/uploadImage', // 后端api接口
					filePath: path, // uni.chooseImage函数调用后获取的本地文件路劲
					header:header,
					name: 'file', //后端通过'file'获取上传的文件对象
					success: (res) => {
						if (res.statusCode == 200) {
							resolve( JSON.parse(res.data))
						}
					},
					complete(res) {
					}
				})
	})
}
export default httpUpload;